﻿<views:MvxWpfView 
	x:Class="Sidvall.AuthorizationManager.UI.Wpf.Views.AuthorizationScopeView"
	xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:views="clr-namespace:MvvmCross.Wpf.Views;assembly=MvvmCross.Wpf"
	xmlns:vms="clr-namespace:Sidvall.AuthorizationManager.UI.ViewModels;assembly=Sidvall.AuthorizationManager.UI"
	xmlns:Controls="clr-namespace:Sidvall.AuthorizationManager.UI.Wpf.Controls" 
	xmlns:Converters="clr-namespace:Sidvall.UI.Wpf.Converters;assembly=Sidvall.UI.Wpf" 
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	xmlns:local="clr-namespace:Sidvall.AuthorizationManager.UI.Wpf.Views"
	xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
	mc:Ignorable="d" 
	d:DesignHeight="500" d:DesignWidth="800">
	
	<views:MvxWpfView.Resources>
		<Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<Converters:BooleanToVisibilityConverter x:Key="NotBooleanToVisibilityConverter" Not="True"/>
		<CollectionViewSource x:Key="ResourceActions" Source="{Binding ActiveAuthorizationScope.AuthorizationScopeResourceActions}">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="IsEnabled" Direction="Descending" />
				<scm:SortDescription PropertyName="Resources" Direction="Ascending" />
				<scm:SortDescription PropertyName="Actions" Direction="Ascending" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
		<CollectionViewSource x:Key="ResourceItems" Source="{Binding ActiveAuthorizationScope.AuthorizationScopeResourceItems}">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="IsEnabled" Direction="Descending" />
				<scm:SortDescription PropertyName="Resource" Direction="Ascending" />
				<scm:SortDescription PropertyName="Actions" Direction="Ascending" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
		<CollectionViewSource x:Key="AuthorizationScopeExports" Source="{Binding ActiveAuthorizationScope.AuthorizationScopeExports}">
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="IsEnabled" Direction="Descending" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
	</views:MvxWpfView.Resources>

	<Grid d:DataContext="{d:DesignInstance IsDesignTimeCreatable=True, Type={x:Type vms:AuthorizationScopeViewModel}}">
		<Grid.Background>
			<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.InactiveBorderColorKey}}"/>
		</Grid.Background>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition/>
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="180" />
			<ColumnDefinition />
		</Grid.ColumnDefinitions>

		<Controls:HeaderControl Grid.ColumnSpan="2" HeaderCaption="{Binding Title}" />

		<Grid Grid.Row="1">
			<Grid.Background>
				<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
			</Grid.Background>
			<StackPanel Orientation="Horizontal">
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
										ToolTip="Add" ButtonText="{Binding AddTreeItemCaption}" IsEnabled="{Binding CanAddTreeItem}" ButtonCommand="{Binding AddTreeItemCommand}" />
			</StackPanel>
		</Grid>
		<DataGrid Grid.Row="2" ItemsSource="{Binding TreeItems}" AutoGenerateColumns="False" HeadersVisibility="None" CanUserReorderColumns="False" CanUserResizeColumns="False" RowHeaderWidth="0"
			CanUserResizeRows="False" CanUserSortColumns="False" SelectionMode="Single" CanUserAddRows="False" SelectedItem="{Binding ActiveTreeItem, Mode=TwoWay}" AllowDrop="True" Background="#FFF0F0F0">
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="SelectionChanged">
					<i:InvokeCommandAction Command="{Binding SelectTreeItemCommand}" />
				</i:EventTrigger>
			</i:Interaction.Triggers>
			<DataGrid.Columns>
				<DataGridTemplateColumn Width="*">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Grid>
								<Grid Visibility="{Binding IsServer, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="{Binding ItemTooltip}" Background="#FF6AA8C5">
									<Grid.RowDefinitions>
										<RowDefinition Height="40" />
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="40" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>
									<Image Margin="5" Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Server.png" Stretch="UniformToFill" />
									<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" ForceCursor="False" />
								</Grid>
								<Grid Visibility="{Binding IsAuthorizationScope, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="{Binding ItemTooltip}">
									<Grid.RowDefinitions>
										<RowDefinition Height="30" />
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="30" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>
									<Image Margin="5" Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Application.png" Stretch="UniformToFill" />
									<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
									<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="5,0,0,0" VerticalAlignment="Center" Visibility="{Binding IsEnabled, Converter={StaticResource NotBooleanToVisibilityConverter}}" Opacity="0.2" />
								</Grid>
							</Grid>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
			</DataGrid.Columns>
		</DataGrid>

		<Grid Grid.Row="1" Grid.Column="1">
			<Grid.Background>
				<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
			</Grid.Background>
			<StackPanel Orientation="Horizontal">
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Save.png" 
										ToolTip="Save" ButtonCommand="{Binding SaveActiveTreeItemCommand}" IsEnabled="{Binding CanSave}" />
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Refresh.png" 
										ToolTip="Reload" ButtonCommand="{Binding SelectTreeItemCommand}" IsEnabled="{Binding CanSave}" />
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" 
										ToolTip="Remove" ButtonCommand="{Binding DeleteActiveTreeItemCommand}" IsEnabled="{Binding CanDelete}" />
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Export.png" 
										ToolTip="Export" ButtonCommand="{Binding ExportSettingsCommand}" IsEnabled="{Binding CanDelete}" />
				<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Import.png" 
										ToolTip="Import" ButtonCommand="{Binding ImportSettingsCommand}" IsEnabled="{Binding CanAddTreeItem}" />
			</StackPanel>
		</Grid>
		<Grid Grid.Row="2" Grid.Column="1" Grid.RowSpan="2">
			<Grid.RowDefinitions>
				<RowDefinition/>
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
			</Grid.ColumnDefinitions>

			<Grid Grid.RowSpan="2" Visibility="{Binding InformationIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
				<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="Bold"><Run Text="Select item"/></TextBlock>
			</Grid>

			<Grid Visibility="{Binding ServerIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
				<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20"><Run Text="Server"/></TextBlock>
			</Grid>

			<Grid Visibility="{Binding AuthorizationScopeIsVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition />
				</Grid.ColumnDefinitions>

				<Grid Grid.Row="1">
					<StackPanel>
						<Grid Margin="5,5,5,0">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="130" />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<Label Content="Id"/>
							<TextBox Grid.Column="1" Text="{Binding ActiveAuthorizationScope.AuthorizationScopeId, Mode=OneWay}" Width="80" HorizontalAlignment="Left" IsReadOnly="True" />
						</Grid>
						<Grid Margin="5,5,5,0">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="130" />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<Label Content="Name"/>
							<TextBox Grid.Column="1" Text="{Binding ActiveAuthorizationScope.Name}" />
						</Grid>
						<Grid Margin="5,5,5,0">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="130" />
								<ColumnDefinition Width="200" />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<Label Content="Is Enabled"/>
							<CheckBox Grid.Column="1" IsChecked="{Binding ActiveAuthorizationScope.IsEnabled}" VerticalAlignment="Center" />
						</Grid>
					</StackPanel>
				</Grid>
				<TabControl Grid.Row="2" Margin="5,5,5,0">
					<TabItem Header="Settings">
						<Grid>
							<StackPanel>
								<Grid Margin="0,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Execution Policy"/>
									<ComboBox Grid.Column="1" Width="300" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.ResourceItemPolicyId}" ItemsSource="{Binding ResourceItemActionPolicies}" />
								</Grid>
								<Grid Margin="0,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Missing user policy"/>
									<ComboBox Grid.Column="1" Width="300" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.MissingUserPolicyId}" ItemsSource="{Binding MissingUserPolicies}" />
								</Grid>
								<Grid Margin="0,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Default User Context:"/>
									<TextBox Grid.Column="1" Height="60" Text="{Binding ActiveAuthorizationScope.DefaultUserContext}" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
								</Grid>
								<Grid Margin="0,5,0,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition Width="200" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Require Active User"/>
									<CheckBox Grid.Column="1" IsChecked="{Binding ActiveAuthorizationScope.RequireActiveUser}" VerticalAlignment="Center" />
								</Grid>
							</StackPanel>
						</Grid>
					</TabItem>
					<TabItem Header="Resource Actions">
						<Grid>
							<Grid Visibility="{Binding ResourceActionListIsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid>
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add resource action" ButtonCommand="{Binding AddResourceActionCommand}" />
									</StackPanel>
								</Grid>
								<Grid Grid.Row="1" Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Default Access Level"/>
									<ComboBox Grid.Column="1" Width="200" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.DefaultResourceActionAccessLevel}" ItemsSource="{Binding AuthorizationScopeAccessLevels}" />
								</Grid>
								<DataGrid Grid.Row="2" Margin="0,5,0,0" RowHeaderWidth="0" ItemsSource="{Binding Source={StaticResource ResourceActions}}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" SelectedItem="{Binding ActiveResourceAction}">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="55" Header="Enabled" SortMemberPath="IsEnabled">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="45" Header="Items" SortMemberPath="ValidForResourceActionItems">
											<DataGridTemplateColumn.HeaderStyle>
												<Style TargetType="DataGridColumnHeader">
													<Setter Property="ToolTip" Value="Valid for resource items" />
												</Style>
											</DataGridTemplateColumn.HeaderStyle>
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding ValidForResourceActionItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="120" Header="Access Level" SortMemberPath="AccessLevel">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="False" ItemsSource="{Binding DataContext.ResourceAccessLevels, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" SelectedValuePath="Value" DisplayMemberPath="Key" Text="{Binding AccessLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Resources" SortMemberPath="Resources">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding Resources, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Actions" SortMemberPath="Actions">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ResourceActionOptions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" DisplayMemberPath="Name" SelectedValuePath="Name" Text="{Binding Actions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" ToolTip="{Binding Actions}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Sub Actions" SortMemberPath="SubActions">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding SubActions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="50" Header="Claims" SortMemberPath="AuthorizationScopeResourceActionClaims.Count">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBlock Text="{Binding AuthorizationScopeResourceActionClaims.Count}" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Controls:ButtonControl ImageHeight="32" ImageWidth="32" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Edit.png" 
														ButtonCommand="{Binding DataContext.EditClaimsCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" 
														ButtonCommandParameter="{Binding}" ToolTip="Edit claims" IsEnabled="{Binding CanEditClaims}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteResourceActionCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete resource action" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
							<Grid Visibility="{Binding ResourceActionListIsVisible, Converter={StaticResource NotBooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid Grid.ColumnSpan="3">
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Back.png" 
											ToolTip="Back to list" ButtonCommand="{Binding ShowResourceActionListCommand}" />
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add claim" ButtonCommand="{Binding AddClaimCommand}" />
									</StackPanel>
								</Grid>
								<DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveResourceAction.AuthorizationScopeResourceActionClaims}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False" RowHeight="50">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="60" Header="Enabled">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="ClaimType">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ValidClaims, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" DisplayMemberPath="ClaimType" SelectedValuePath="ClaimType" Text="{Binding ClaimType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="150" Header="Comparison">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ComparisonOperator, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ComparisonOperators, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="150" Header="Value">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteClaimCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete claim" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
						</Grid>
					</TabItem>
					<TabItem Header="Resource Items">
						<Grid>
							<Grid Visibility="{Binding ResourceItemListIsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid>
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add resource item" ButtonCommand="{Binding AddResourceItemCommand}" />
									</StackPanel>
								</Grid>
								<Grid Grid.Row="1" Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="130" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Default Access Level"/>
									<ComboBox Grid.Column="1" Width="200" HorizontalAlignment="Left" SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ActiveAuthorizationScope.DefaultResourceItemAccessLevel}" ItemsSource="{Binding AuthorizationScopeAccessLevels}" />
								</Grid>
								<DataGrid Grid.Row="3" Margin="0,5,0,0" RowHeaderWidth="0" ItemsSource="{Binding Source={StaticResource ResourceItems}}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" SelectedItem="{Binding ActiveResourceItem}">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="55" Header="Enabled" SortMemberPath="IsEnabled">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="120" Header="Access Level" SortMemberPath="AccessLevel">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="False" ItemsSource="{Binding DataContext.ResourceAccessLevels, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" SelectedValuePath="Value" DisplayMemberPath="Key" Text="{Binding AccessLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Resource" SortMemberPath="Resource">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding Resource, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="40" Header="Id" SortMemberPath="ResourceItemId">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding ResourceItemId, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Actions" SortMemberPath="Actions">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ResourceItemActionOptions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" DisplayMemberPath="Name" SelectedValuePath="Name" Text="{Binding Actions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Sub Actions" SortMemberPath="SubActions">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding SubActions, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="50" Header="Claims" SortMemberPath="AuthorizationScopeResourceItemClaims.Count">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBlock Text="{Binding AuthorizationScopeResourceItemClaims.Count}" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Controls:ButtonControl ImageHeight="32" ImageWidth="32" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Edit.png" 
														ButtonCommand="{Binding DataContext.EditItemClaimsCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" 
														ButtonCommandParameter="{Binding}" ToolTip="Edit claims" IsEnabled="{Binding CanEditClaims}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteResourceItemCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete resource item" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
							<Grid Visibility="{Binding ResourceItemListIsVisible, Converter={StaticResource NotBooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid Grid.ColumnSpan="3">
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Back.png" 
											ToolTip="Back to list" ButtonCommand="{Binding ShowResourceItemListCommand}" />
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add claim" ButtonCommand="{Binding AddItemClaimCommand}" />
									</StackPanel>
								</Grid>
								<DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveResourceItem.AuthorizationScopeResourceItemClaims}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False" RowHeight="50">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="60" Header="Enabled">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="ClaimType">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ValidClaims, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" DisplayMemberPath="ClaimType" SelectedValuePath="ClaimType" Text="{Binding ClaimType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="150" Header="Comparison">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<ComboBox SelectedValuePath="Value" DisplayMemberPath="Key" SelectedValue="{Binding ComparisonOperator, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ComparisonOperators, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="150" Header="Value">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteItemClaimCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete claim" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
						</Grid>
					</TabItem>
					<TabItem Header="Users">
						<Grid>
							<Grid Visibility="{Binding UserListIsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid>
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add user" ButtonCommand="{Binding AddUserCommand}" />
									</StackPanel>
								</Grid>
								<DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveAuthorizationScope.AuthorizationScopeUsers}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" SelectedItem="{Binding ActiveUser}">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="*" Header="User" SortMemberPath="UserId">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding UserId, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="140" Header="Created" SortMemberPath="CreatedTime">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBlock Text="{Binding CreatedTime}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="140" Header="Accessed" SortMemberPath="UpdatedTime">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBlock Text="{Binding UpdatedTime}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="140" Header="Updated" SortMemberPath="AccessTime">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBlock Text="{Binding AccessTime}" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="55" Header="Active" SortMemberPath="IsActive">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsActive, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.EditUserCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Edit.png" ToolTip="Edit user" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteUserCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete user" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
							<Grid Visibility="{Binding UserListIsVisible, Converter={StaticResource NotBooleanToVisibilityConverter}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid>
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Back.png" 
											ToolTip="Back to list" ButtonCommand="{Binding ShowUserListCommand}" />
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add user claim" ButtonCommand="{Binding AddUserClaimCommand}" />
									</StackPanel>
								</Grid>
								<Grid Grid.Row="1">
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto" />
										<RowDefinition />
									</Grid.RowDefinitions>
									<Label Content="User Claims:"/>
									<DataGrid Grid.Row="1" RowHeaderWidth="0" ItemsSource="{Binding ActiveUserClaims}" AutoGenerateColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserAddRows="False">
										<DataGrid.Columns>
											<DataGridTemplateColumn Width="*" Header="ClaimType">
												<DataGridTemplateColumn.CellTemplate>
													<DataTemplate>
														<ComboBox IsEditable="True" ItemsSource="{Binding DataContext.ValidUserClaims, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}" DisplayMemberPath="ClaimType" SelectedValuePath="ClaimType" Text="{Binding ClaimType, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
													</DataTemplate>
												</DataGridTemplateColumn.CellTemplate>
											</DataGridTemplateColumn>
											<DataGridTemplateColumn Width="150" Header="Value">
												<DataGridTemplateColumn.CellTemplate>
													<DataTemplate>
														<TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" AcceptsReturn="True" />
													</DataTemplate>
												</DataGridTemplateColumn.CellTemplate>
											</DataGridTemplateColumn>
											<DataGridTemplateColumn Width="35" IsReadOnly="True">
												<DataGridTemplateColumn.CellTemplate>
													<DataTemplate>
														<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteUserClaimCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
															<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete user claim" />
														</Button>
													</DataTemplate>
												</DataGridTemplateColumn.CellTemplate>
											</DataGridTemplateColumn>
										</DataGrid.Columns>
									</DataGrid>
								</Grid>
								<Grid Grid.Row="2">
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto" />
										<RowDefinition />
									</Grid.RowDefinitions>
									<Label Content="User Context:"/>
									<TextBox Grid.Row="1" Height="100" Text="{Binding ActiveUserContext}" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" />
								</Grid>
							</Grid>
						</Grid>
					</TabItem>
					<TabItem Header="Export to files">
						<Grid>
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition />
									<RowDefinition Height="Auto" />
								</Grid.RowDefinitions>

								<Grid>
									<Grid.Background>
										<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
									</Grid.Background>
									<StackPanel Orientation="Horizontal">
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Add.png" 
											ToolTip="Add export" ButtonCommand="{Binding AddExportCommand}" />
										<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Export.png" 
											ToolTip="Export to files" ButtonCommand="{Binding ExportToFilesCommand}" IsEnabled="{Binding CanDelete}" />
									</StackPanel>
								</Grid>
								<DataGrid Grid.Row="2" Margin="0,5,0,0" RowHeaderWidth="0" ItemsSource="{Binding Source={StaticResource AuthorizationScopeExports}}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False">
									<DataGrid.Columns>
										<DataGridTemplateColumn Width="55" Header="Enabled" SortMemberPath="IsEnabled">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="55" Header="Create" SortMemberPath="CreateMissingFile">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding CreateMissingFile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="100" SortMemberPath="IncludeResourceItems">
											<DataGridTemplateColumn.HeaderTemplate>
												<DataTemplate>
													<TextBlock Text="Include Resource Items" TextWrapping="Wrap" HorizontalAlignment="Center"/>
												</DataTemplate>
											</DataGridTemplateColumn.HeaderTemplate>
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IncludeResourceItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="75" SortMemberPath="IncludeUserItems">
											<DataGridTemplateColumn.HeaderTemplate>
												<DataTemplate>
													<TextBlock Text="Include User Items" TextWrapping="Wrap" HorizontalAlignment="Center"/>
												</DataTemplate>
											</DataGridTemplateColumn.HeaderTemplate>
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<CheckBox IsChecked="{Binding IncludeUserItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="File path" SortMemberPath="FilePath">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding FilePath, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="*" Header="Xml node" SortMemberPath="XmlNode">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<TextBox Text="{Binding XmlNode, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" TextWrapping="Wrap" />
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
										<DataGridTemplateColumn Width="35" IsReadOnly="True">
											<DataGridTemplateColumn.CellTemplate>
												<DataTemplate>
													<Button Width="32" Height="32" Background="{x:Null}" BorderBrush="{x:Null}" 
															Command="{Binding DataContext.DeleteExportCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:AuthorizationScopeView}}}"
															CommandParameter="{Binding}">
														<Image Source="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Delete.png" ToolTip="Delete export" />
													</Button>
												</DataTemplate>
											</DataGridTemplateColumn.CellTemplate>
										</DataGridTemplateColumn>
									</DataGrid.Columns>
								</DataGrid>
							</Grid>
						</Grid>
					</TabItem>
					<TabItem Header="Export to JSON">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>

							<Grid Grid.ColumnSpan="3">
								<Grid.Background>
									<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
								</Grid.Background>
								<StackPanel Orientation="Horizontal">
									<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/Export.png" 
										ToolTip="Export to JSON" ButtonCommand="{Binding ExportJsonContentCommand}" IsEnabled="{Binding CanDelete}" />
								</StackPanel>
							</Grid>
							<Grid Grid.Row="1" Margin="5,5,5,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="50" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="50" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="50" />
									<ColumnDefinition />
								</Grid.ColumnDefinitions>

								<Label Content="Formatted"/>
								<CheckBox Grid.Column="1" IsChecked="{Binding JsonContentIsFormatted}" VerticalAlignment="Center" />
								<Label Grid.Column="2" Content="Include Resource Items"/>
								<CheckBox Grid.Column="3" IsChecked="{Binding JsonContentIncludeResourceItems}" VerticalAlignment="Center" />
								<Label Grid.Column="4" Content="Include User Items"/>
								<CheckBox Grid.Column="5" IsChecked="{Binding JsonContentIncludeUserItems}" VerticalAlignment="Center" />
							</Grid>
							<TextBox Grid.Row="2" Text="{Binding JsonContent, Mode=OneWay}" IsReadOnly="True" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Visible" />
						</Grid>
					</TabItem>
					<TabItem Header="Test Authorization">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>

							<Grid Grid.ColumnSpan="3">
								<Grid.Background>
									<SolidColorBrush Color="#FFD1E0F1" Opacity="0.6"/>
								</Grid.Background>
								<StackPanel Orientation="Horizontal">
									<Controls:ButtonControl ImageHeight="36" ImageWidth="36" ImageSource="/Sidvall.AuthorizationManager.UI.Wpf;component/Images/User.png" 
										ToolTip="Authorize User" ButtonCommand="{Binding AuthorizeUserCommand}" ButtonText="Authorize User" />
								</StackPanel>
							</Grid>
							<StackPanel Grid.Row="1">
								<Grid Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="90" />
										<ColumnDefinition Width="200" />
										<ColumnDefinition Width="110" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Grid.Column="0" Content="User Name:"/>
									<TextBox Grid.Column="1" Text="{Binding AuthorizationContext.UserName}" />
								</Grid>
								<Grid Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="90" />
										<ColumnDefinition Width="200" />
										<ColumnDefinition Width="110" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Resource:"/>
									<TextBox Grid.Column="1" Text="{Binding AuthorizationContext.Resource}" />
									<Label Grid.Column="2" Content="Resource Item Id:"/>
									<TextBox Grid.Column="3" Text="{Binding AuthorizationContext.ResourceItemId}" />
								</Grid>
								<Grid Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="90" />
										<ColumnDefinition Width="200" />
										<ColumnDefinition Width="110" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Action:"/>
									<TextBox Grid.Column="1" Text="{Binding AuthorizationContext.Action}" />
									<Label Grid.Column="2" Content="Sub Action:"/>
									<TextBox Grid.Column="3" Text="{Binding AuthorizationContext.SubAction}" />
								</Grid>
								<Grid Margin="5,5,5,0">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="90" />
										<ColumnDefinition Width="200" />
										<ColumnDefinition Width="110" />
										<ColumnDefinition />
									</Grid.ColumnDefinitions>

									<Label Content="Claim Type:"/>
									<TextBox Grid.Column="1" Text="{Binding AuthorizationContext.ClaimType}" />
									<Label Grid.Column="2" Content="Claim Value:"/>
									<TextBox Grid.Column="3" Text="{Binding AuthorizationContext.ClaimValue}" />
								</Grid>
							</StackPanel>
						</Grid>
					</TabItem>
				</TabControl>
			</Grid>
		</Grid>
	</Grid>
</views:MvxWpfView>
